<template>
    <el-upload
      class="avatar-uploader"
      action="https://jsonplaceholder.typicode.com/posts/"
      :show-file-list="false"
      :on-success="handleSuccess"
    >
      <img v-if="imageUrl" :src="imageUrl" class="avatar" />
      <div v-else class="avatar-box">
        <span class="avatar-text">上传图片</span>
      </div>
      <span
        class="avatar-del el-icon-circle-close"
        @click.stop="$emit('ondelete')"
      ></span>
    </el-upload>
</template>

<script>
export default {
  name: '',
  props: {
    imageUrl: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
    }
  },
  components: {},
  created () {},
  mounted () {},
  methods: {
    handleSuccess () {
      this.$emit('onsuccess', ...arguments)
    }
  }
}
</script>
<style lang="scss" scoped></style>
